

library(ggplot2)
library(patchwork)

data1 <- c(
  33.48,
  42.53,
  48.53,
  30.21,
  38.76,
  38.59,
  52.93,
  32.65,
  52.42,
  22.22,
  41.4,
  16.28,
  40.83,
  24.43,
  56.38
)

data2 <- c(112, 94, 118, 87, 96, 106, 71, 91, 95, 94, 100, 98, 94, 113, 85)

data3 <- c(12, 14, 18, 10, 13, 22, 17, 15, 16, 9, 19, 8, 20, 11, 21)

data4 <- c(2.2,
           3.2,
           3.4,
           1.8,
           2.8,
           0.2,
           4.4,
           1.0,
           4.6,
           0.4,
           1.6,
           0.0,
           1.2,
           0.6,
           4.2)

x_data <- data.frame(
  suc = data1,
  iq = data2,
  year_scholl = data3,
  grit = data4
)

p1 <- ggplot(data = x_data, aes(y = suc)) +
  geom_boxplot(fill = 'lightblue') +
  labs(title = 'success', y = 'success') +
  theme_minimal() +
  theme(
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.ticks = element_blank()
  )

p2 <- ggplot(data = x_data, aes(y = iq)) +
  geom_boxplot(fill = 'lightgreen') +
  labs(title = 'iq', y = 'iq') +
  theme_minimal() +
  theme(
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.ticks = element_blank()
  )

p3 <- ggplot(data = x_data, aes(y = year_scholl)) +
  geom_boxplot(fill = 'lightgreen') +
  labs(title = 'year_scholl', y = 'year_scholl') +
  theme_minimal() +
  theme(
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.ticks = element_blank()
  )

p4 <- ggplot(data = x_data, aes(y = grit)) +
  geom_boxplot(fill = 'lightblue') +
  labs(title = 'grit', y = 'grit') +
  theme_minimal() +
  theme(
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.ticks = element_blank()
  )

p5 <- ggplot(data=x_data, aes(x=iq, y=suc)) +
  geom_point(color="blue",size=3)+
  labs(title = 'iq vs suc', x='iq', y='suc') +
  theme_minimal()

p6 <- ggplot(data=x_data, aes(x=year_scholl, y=suc)) +
  geom_point(color="red",size=3)+
  labs(title = 'year_scholl vs suc', x='year_scholl', y='suc') +
  theme_minimal()

p7 <- ggplot(data=x_data, aes(x=grit, y=suc)) +
  geom_point(color="green",size=3)+
  labs(title = 'grit vs suc', x='grit', y='suc') +
  theme_minimal()


(p1 + p2) / (p3 + p4) / (p5 + p6) / (p7 + plot_spacer())
